-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix QIT errors reported by PHPStan #8845
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: 0 B Total Size: 1.23 MB ℹ️ View Unchanged
|
3f9324b
to
e7aaf6c
Compare
4986fb9
to
53a8480
Compare
…into fix/phpstan-errors
d89a7cc
to
e0f96bf
Compare
@@ -55,6 +55,7 @@ public function get_args() { | |||
* @psalm-suppress UndefinedMethod | |||
*/ | |||
public function get_cart_token() { | |||
// @phpstan-ignore-next-line. | |||
return parent::get_cart_token(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine to ignore 👍.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ricardo ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that others might still be reviewing as the fixes here touch various different product areas. Confirming that QIT PHPStan tests are now successful with no errors.
@@ -63,7 +63,7 @@ public function add_initial_currency( $cart_item, $product_id, $variation_id ) { | |||
|
|||
$nyp_id = $variation_id ? $variation_id : $product_id; | |||
|
|||
if ( \WC_Name_Your_Price_Helpers::is_nyp( $nyp_id ) && isset( $cart_item['nyp'] ) ) { | |||
if ( class_exists( '\WC_Name_Your_Price_Helpers' ) && \WC_Name_Your_Price_Helpers::is_nyp( $nyp_id ) && isset( $cart_item['nyp'] ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check makes sense since we were assuming the Name Your Price plugin would always have the helper class when it may not.
@@ -125,8 +125,10 @@ public function get_item_data( $addon_data, $addon, $cart_item ): array { | |||
// Quantity/multiplier add on needs to be split, calculated, then multiplied by input value. | |||
$price = $this->multi_currency->get_price( $addon['price'] / $addon['value'], 'product' ) * $addon['value']; | |||
} | |||
$price = \WC_Product_Addons_Helper::get_product_addon_price_for_display( $price, $cart_item['data'] ); | |||
$name .= ' (' . wc_price( $price ) . ')'; | |||
if ( class_exists( '\WC_Product_Addons_Helper' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check makes sense since we were assuming the Product Addons plugin would always have the helper class when it may not.
…into fix/phpstan-errors
Fixes #8817
Changes proposed in this Pull Request
This PR fixes the PHPStan errors reported by QIT tests.
Testing instructions
npm run test:qit-phpstan-local
on thedevelop
branch reveals 27 errors.npm run test:qit-phpstan-local
on this branch results in a successful test outcome.npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge